import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getx_learn/app/common/widgets/widgets.dart';

import '../controllers/obx_fun3_controller.dart';

class ObxFun3View extends GetView<ObxFun3Controller> {
  const ObxFun3View({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(context: context, title: ".obs的方式"),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Obx(
                  () => Text(
                "count的值为: ${controller.count}",
                style: TextStyle(color: Colors.red, fontSize: 30),
              ),
            ),

            Obx(
                  () => Text(
                "name的值为: ${controller.name}",
                style: TextStyle(color: Colors.red, fontSize: 30),
              ),
            ),
            SizedBox(
              height: 20,
            ),
            ElevatedButton(
              onPressed: () {
                controller.increment();
              },
              child: Text("点我加1"),
            ),
            ElevatedButton(
              onPressed: () {
                controller.changeName();
              },
              child: Text("改变名称"),
            )
          ],
        ),
      ),
    );
  }
}
